package responses

import (
	"github.com/edgexfoundry/edgex-go/internal/app/dtos"
	"github.com/edgexfoundry/edgex-go/internal/app/models"
	edgexDtos "github.com/edgexfoundry/go-mod-core-contracts/v2/dtos"
	"github.com/edgexfoundry/go-mod-core-contracts/v2/dtos/common"
)

type DeviceProfileResponse struct {
	common.BaseResponse `json:",inline"`
	Profile             dtos.DeviceProfile `json:"profile"`
}

func NewDeviceProfileResponse(requestId string, message string, statusCode int, deviceProfile dtos.DeviceProfile) DeviceProfileResponse {
	return DeviceProfileResponse{
		BaseResponse: common.NewBaseResponse(requestId, message, statusCode),
		Profile:      deviceProfile,
	}
}

func ToDeviceProfileDTO(d models.DeviceProfile) dtos.DeviceProfile {
	return dtos.DeviceProfile{
		DeviceProfile:   edgexDtos.FromDeviceProfileModelToDTO(d.DeviceProfile),
		DeviceResources: ToDeviceResourceDTOs(d.DeviceResources),
		DeviceCommands:  ToDeviceCommandDTOs(d.DeviceCommands),
	}
}
